import React,{Component} from 'react';



import {getPlaylist} from '../../service/api';


interface State {
    playlist:any[],

}
export default  class PlayList extends Component<{},State>{

    constructor(prop){
        super(prop);
        this.state  = {
            playlist:[]
        }
    }
    componentWillMount(){
        this.loadPlaylist();
    }

    loadPlaylist(){
        getPlaylist().then(res=>{
            console.log(res)
            this.setState({playlist:res.playlists})
        })
    }

    render(){
        return (<div>
           <div className="main">
                {this.state.playlist.map(playitem=>(
                    <img className="img" key={playitem.id} src={playitem.coverImgUrl} alt=""/>
                ))}
           </div>
        </div>)
    }
}